Brief introduction and use of rviz2

rviz is a three-dimensional visualization platform in ROS. On the one hand, it can realize the graphical display of external information, and on the other hand, it can also release control information to the object through rviz, so as to realize the monitoring and control of the robot.

1 Introduction to rviz2

The successful installation of ros2 indicates that rviz2 is also successfully installed together, because the installation of ros2 includes rviz2.

Open a new terminal (shortcutCtrl+Alt+T)enter the command to open rviz2

Open rviz2 and display the following interface:

img

2 Introduction of each area

We only give a rough introduction in this part. If you want to know more detailed content, you can go to the user guide to view it.

3 mycobot_ros2 installation and update

Launch via launch.py file

This example is based on the fact that you have completed the environment setup and successfully copied the company's code from GitHub.。

Open a console terminal (shortcutCtrl+Alt+T) Enter the following command to configure the ROS2 environment .

Enter again:

image-20220519154216114

Open rviz and get the following result:

img

If you want to know more information about rviz, you can go to the official documentation to view it.

5 M5 Version Prerequisites

Then enter the user password(Note: The password is not displayed, just enter it correctly).

 

Control and follow-up of the robotic arm

1 Slider Control

Open a command line and run:

It will open rviz and a slider component and you will see something like this:

img

Then you can control the movement of the model in rviz by dragging the slider . The real mycobot will move with it.

Please note: Since the robot arm will move to the current position of the model when the command is input, please make sure that the model in rviz does not appear to be worn out before you use the command Do not quickly drag the slider after connecting the robotic arm to prevent damage to the robotic arm

2 Model Follow

In addition to the above controls, we can also make the model follow the movement of the real robotic arm . Open a command line and run:

It will open rviz to show the model following effect .

3 GUI Control

On the basis of the previous, this package also provides a simple GUI control interface . This method means that the real robotic arms are linked with each other, please connect to mycobot.

Open the command line::

img

4 Keyboard Control

The function of keyboard control is added in the package of mycobot_320, and it is synchronized in real time in rviz. This function relies on pythonApi, so make sure to connect with the real robotic arm.

Open a command line and run:

The operation effect is as follows:

img

The command line will output mycobot information, as follows:

Next, open another command line and run:

You will see the following output on the command line:

In this terminal, you can control the state of the robot arm and move the robot arm through the keys in the command line.